import java.util.Date;
import java.util.Deque;
import java.util.concurrent.TimeUnit;


public class WriteTask implements Runnable {
    private Deque<Event> mQues;

    public WriteTask(Deque<Event> mQues) {
        super();
        this.mQues = mQues;
    }

    @Override
    public void run() {
        if (mQues != null) {
            for (int i = 0; i < 40 || mQues.size() < 10; i++) {
                try {
                    Date date = new Date(System.currentTimeMillis());
                    Event enEvent = new Event(date);
                    mQues.addFirst(enEvent);
                    TimeUnit.SECONDS.sleep(1);
                    System.out.println(mQues.size());
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }

    }

}
